<!DOCTYPE html>
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
  <head>
    <title></title>
    <meta charset="UTF-8">
    <script src="../html-imports.js"></script>
    <link rel="import" href="components/markup-component.html">
  </head>
  <body>
    <script>
      window.addEventListener('HTMLImportsLoaded', function() {
        console.dir(HTMLImports.cache);
        console.log('done');
        
        var link = document.querySelector('link');
        console.log(link.__resource);
        var img = link.__resource.querySelector('img');
        document.body.appendChild(img);
        
        var sheet = link.__resource.querySelector('link[rel=stylesheet]');
        var style = document.createElement('style');
        style.textContent = sheet.__resource;
        document.head.appendChild(style);
        var div = document.createElement('div');
        div.className = 'mail';
        document.body.appendChild(div);
        
        
        var sheet2 = link.__resource.querySelector('link[rel=stylesheet]:nth-of-type(2)');
        document.head.appendChild(sheet2);
        var div = document.createElement('div');
        div.className = 'mail2';
        document.body.appendChild(div);
        
        
        document.body.appendChild(document.createElement('br'));
        
        // try markup-component-more.html
        var linkedDoc = link.__resource;
        var moreLink = linkedDoc.querySelector('link[rel=import]');
        var img = moreLink.__resource.querySelector('img');
        document.body.appendChild(img);
        
        var sheet = moreLink.__resource.querySelector('link[rel=stylesheet]');
        var style = document.createElement('style');
        style.textContent = sheet.__resource;
        document.head.appendChild(style);
        var div = document.createElement('div');
        div.className = 'mail3';
        document.body.appendChild(div);
        
        
        var sheet2 = moreLink.__resource.querySelector('link[rel=stylesheet]:nth-of-type(2)');
        document.head.appendChild(sheet2);
        var div = document.createElement('div');
        div.className = 'mail4';
        document.body.appendChild(div);
        
      });
    </script>
  </body>
</html>
